<template>
	<view class="wrap">
		<view class="topBc"></view>
		<view class="content formLengthWrap">
			<view class="title" style="margin-top: 0;">进口设备减免税情况</view>
			
			<!-- 数据不全，开发中 -->
			
			<!-- <u-form :model="formData" ref="uForm" :rules="rules">
				<u-form-item v-if="formKeys.imeqduty" label="是否享受国家规定的进口设备减免税" prop="imeqduty" label-width="auto" borderBottom>
					<u-radio-group v-model="formData.imeqduty" placement="row">
						<u-radio v-for="item,index in stateRangesA" :key="index" :label="item.text" :name="item.value" :activeColor="bgColor"></u-radio>
					</u-radio-group>
				</u-form-item>
				
				<template v-if="formData.imeqduty == '1'">
					<view class="textLength u-checkbox-group_wrap">
						<u-form-item v-if="formKeys.forinvindustryCode" label="国家鼓励外商投资的产业" prop="forinvindustryCode" label-width="auto" borderBottom>
							<u-checkbox-group v-model="formData.forinvindustryCode" placement="row">
								<u-checkbox :activeColor="bgColor" label="实物" v-for="ite,ind in 10" :key="ind"></u-checkbox>
							</u-checkbox-group>
						</u-form-item>
					</view>
					<view class="textLength u-checkbox-group_wrap">
						<u-form-item v-if="formKeys.cenwesforinvindCode" label="中西部地区外商投资优势产业" prop="cenwesforinvindCode" label-width="auto" borderBottom>
							<u-checkbox-group v-model="formData.cenwesforinvindCode" placement="row">
								<u-checkbox :activeColor="bgColor" label="实物" v-for="ite,ind in 10" :key="ind"></u-checkbox>
							</u-checkbox-group>
						</u-form-item>
					</view>
				</template>
				
			</u-form> -->
			
		</view>
		<view class="submitBtn_bc"></view>
		<view class="submitBtn_ubtn">
			<u-button :disabled="!$util.submitState(year,state)" @click="submit()">提交</u-button>
		</view>
	</view>
</template>

<script>
export default {
	data(){
		return{
			minFormName: 'dutyFreeinfo', //小表单类型名
			regnoInfo: this.$store.state.regnoInfo,
			year: '',
			state: '',
			bgColor: this.$config.bgColor,
			
			stateRangesA: [
				{text: '是',value: '1'},
				{text: '否',value: '0'}
			],
			stateRangesB: [
				{text: '外商投资的投资性公司',value: '1'},
				{text: '外商投资的创业投资企业',value: '2'},
				{text: '外商投资的以投资为主要业务合伙企业',value: '3'},
				{text: '不涉及以上类型',value: '4'}
			],
			formData: {
				installlocation: '',
				handlingsituation: '',
				illegalused: '',
				
				thesameasdeclare: '',
				recapitalise: '',
				isfixedassets: '',
				othermatters: '',
			},
			rules: {
				installlocation: {type:'number',required: true,message: '请选择',trigger: ['blur','change']},
				handlingsituation: {type:'number',required: true,message: '请选择',trigger: ['blur','change']},
				illegalused: {type:'number',required: true,message: '请选择',trigger: ['blur','change']},
				
				thesameasdeclare: {type:'number',required: true,message: '请选择',trigger: ['blur','change']},
				recapitalise: {type:'number',required: true,message: '请选择',trigger: ['blur','change']},
				isfixedassets: {type:'number',required: true,message: '请选择',trigger: ['blur','change']},
				othermatters: {type:'string',required: true,message: '内容输入有误',trigger: ['blur','change']},
			},

			
		}
	},
	onLoad(option) {
		this.year = option.year;
		this.state = option.state;
		this.getFormKey();
		this.getFormData();
	},
	onReady() {
		this.$refs.uForm.setRules(this.rules)
	},
	methods:{
		// 获取小表单数据
		getFormData(){
			let url = this.$typeData.minFormUrl.get(this.minFormName);
			if(!url){
				uni.showModal({
					title: '暂无接口'
				})
				return;
			}
			this.$http.sendRequest({
				url: url,
				data: {
					regno: this.regnoInfo.regno,
					ancheyear: this.year
				}
			})
			.then(res=>{
				console.log('接口返回',res.data);
				let data = res.data;
				let keys = Object.keys(this.formKeys);
				keys.forEach(item=>{
					this.formData[item] = data[item];
				})
				console.log(789789,this.formData);
			})
			.catch(err=>{})
		},
		//获取小表单拥有字段
		getFormKey(){
			let formKeys = this.$util.getFormKeys(this.minFormName,this.regnoInfo.enttype);
			this.formKeys = formKeys;
			let keys = Object.keys(formKeys);
			keys.forEach(item=>{
				this.rules[item] = this.rulesAll[item];
			})
		},
		submit(){
			this.$refs.uForm.validate().then(res => {
				this.saveBtn();
			}).catch(errors => {
				this.$util.showToast({title:'请完善信息'})
			})
		},
		saveBtn(){
			let data = {
				regno: this.regnoInfo.regno,
				ancheyear: this.year,
			}
			data = this.$util.setSaveFormData(this.formKeys,data,this.formData);
			this.$http.sendRequest({
				url: '/annual/report/ws-baseinfo/update-wsdutyfreeinfo',
				method: 'PUT',
				data: data
			})
			.then(res=>{
				this.setRecord();
			})
			.catch(err=>{})
		},
		
		
		
		
		
		//存一下记录
		setRecord(){
			let fillingItem = this.$minFormType.get(this.minFormName);
			this.$http.sendRequest({
				url: '/annual/report/record',
				method: 'POST',
				data: {
					regno: this.regnoInfo.regno,
					year: this.year,
					fillingItem: fillingItem,
					isImp: '0',
				},
				hideLoad: true,
			})
			.then(res=>{
				uni.navigateBack();
			})
			.catch(err=>{})
		},
		goPage(path){
			uni.navigateTo({
				url: path
			})
		},
	}
}
</script>

<style lang="scss">
.wrap{
	width: 100vw;
	min-height: 100vh;
	padding-top: 16rpx;
	box-sizing: border-box;
	position: relative;
	background-color: #FFF;
	
	.topBc{
		height: 10rpx;
		background-color: #F5F6F8;
	}
}

.content{
	padding: 30rpx 36rpx;
	background-color: #FFF;
	
	.title{
		color: #E4B269;
		font-size: 36rpx;
		font-weight: bold;
		border-left: 8rpx solid #E4B269;
		line-height: 40rpx;
		padding-left: 16rpx;
		margin-bottom: 30rpx;
		margin-top: 30rpx;
	}
	
	
}

.u-radio-group_column_wrap{
	.u-radio{
		margin-bottom: 10rpx;
	}
}
.u-checkbox-group_wrap{
	.u-checkbox-group{
		display: flex;
		flex-flow: wrap;
	}
	.u-checkbox{
		margin: 0 10rpx 10rpx;
	}
}
</style>